using System;

namespace UNLV.IAP.WebControls
{
	/// <summary>
	/// Represents an Operator in a SqlWhereBuilder web control.
	/// </summary>
	[Serializable]
	public class SqlWhereBuilderOperator
	{
		private string _id;
		private string _text;
		private string _valueEntryDiv;
		private string _sqlTemplate;

		/// <summary>
		/// Unique identifier for this SqlWhereBuilderOperator object
		/// </summary>
		public string Id
		{
			get {return _id;}
			set {_id = value;}
		}
		
		/// <summary>
		/// Friendly text for display in the Operators dropdown
		/// </summary>
		public string Text
		{
			get {return _text;}
			set {_text = value;}
		}

		/// <summary>
		/// id of the ValueEntryDiv to use when this operator is selected in the Operators dropdown
		/// </summary>
		public string ValueEntryDiv
		{
			get {return _valueEntryDiv;}
			set {_valueEntryDiv = value;}
		}

		
		/// <summary>
		/// a string pattern for translating conditions into SQL Where clause syntax
		/// </summary>
		/// <remarks>
		/// Use <b>#FIELD#</b> as a placeholder for the Field id.  Pound signs (#)
		/// are also used to delimit form field ids in ValueEntry divs, to act
		/// as placeholders for user input.  For example, if the ValueEntry div that
		/// corresponds to this Operator has the following INPUT:
		/// <code>&lt;input type="text" id="text1" /&gt;</code>
		/// then the SqlTemplate for an equals operator might look like:
		/// <code>#FIELD# = '#text1#'</code>
		/// The delimited placeholders are case insensitive.
		/// </remarks>
		public string SqlTemplate
		{
			get {return _sqlTemplate;}
			set {_sqlTemplate = value;}
		}

		
		/// <summary>
		/// Constructs a SqlWhereBuilderOperator object
		/// </summary>
		public SqlWhereBuilderOperator()
		{
		}

		
		/// <summary>
		/// Constructs a SqlWhereBuilderOperator object with all properties set to given values
		/// </summary>
		/// <param name="id">unique id of the Operator</param>
		/// <param name="text">friendly text used for display in the Operators dropdown</param>
		/// <param name="valueEntryDiv">id of the ValueEntryDiv to use when this Operator is selected in the dropdown</param>
		/// <param name="sqlTemplate">string pattern with placeholders for translating a condition using this Operator into SQL Where clause syntax</param>
		public SqlWhereBuilderOperator(string id, string text, string valueEntryDiv, string sqlTemplate)
		{
			this.Id = id;
			this.Text = text;
			this.ValueEntryDiv = valueEntryDiv;
			this.SqlTemplate = sqlTemplate;
		}

	}
}
